<html>
<head>
<script src="resources/jquery-1.6.min.js"></script>
<script>
$(function(){
var txtName = $("<input>").appendTo("body"),
	txtPwd = $("<input>").appendTo("body"),
	btnLogin = $("<button>").text("login").appendTo("body").click(function(){
		$.ajax({
			url:'test/login',
			type:'post',
			data:{name:txtName.val(),pwd:txtPwd.val()},
			success:function(account){
				$("<button>").text("you logined,test permission").click(function(){
					$.ajax({
						url:'test/test',
						type:'get',
						success:function(){
							$("<span>").text("you has permission").appendTo("body");
						},
						error:function(){
							$("<span>").text("you had not enough permission").appendTo("body");
						}
					});
				}).appendTo($("body").empty());
			}
		});
	});
});
</script>
</head>
<body>

</body>
</html>